package com.schoolcloud.serve.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.schoolcloud.common.model.PageDTO;
import com.schoolcloud.serve.dto.GroupAttributeValuesDTO;
import com.schoolcloud.serve.entity.SkuAttrGroup;
import com.schoolcloud.serve.query.SkuAttrGroupQuery;
import com.schoolcloud.serve.service.SkuAttrGroupService;
import com.schoolcloud.serve.mapper.SkuAttrgroupMapper;
import com.schoolcolud.daomybatisplus.dto.MpPageUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author hongmizfb
 * @description 针对表【sku_attrgroup(属性分组信息表)】的数据库操作Service实现
 * @createDate 2025-04-12 17:11:02
 */
@Service
public class SkuAttrgroupServiceImpl extends ServiceImpl<SkuAttrgroupMapper, SkuAttrGroup>
        implements SkuAttrGroupService {

    @Override
    public PageDTO<SkuAttrGroup> getAttrGroupPage(SkuAttrGroupQuery query) {
        Integer spuCategoryId = query.getCategoryId();
        Page<SkuAttrGroup> page = lambdaQuery()
                .eq(spuCategoryId != null, SkuAttrGroup::getCategoryId, spuCategoryId)
                .page(query.toMpPage());
        return MpPageUtil.of(page, SkuAttrGroup.class);
    }

    @Override
    public List<SkuAttrGroup> getAttrGroupByCategoryId(String categoryId) {
        return lambdaQuery().eq(SkuAttrGroup::getCategoryId, categoryId).list();
    }
}




